{% comment %}
/* Copyright 2009 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
{% endcomment %}
{% extends 'admin_base.html' %}
{% block content %}
{% if action %}
{% if confirmation %}
<div class="success">Update Completed!</div>
{% endif %}
<br><br>
  <form method="POST">
    <input type="hidden" name="page" value="{{page.key}}">
    <input type="hidden" name="author" value="{{user.key}}">
    
    
    
    <h3 id="main">Main</h3>
    <div id="main-content">
      <div class="table">
        <div class="row">
          <div class="cell label">
              Title*:
            </div>
            <div class="cell input">
              <input
                class="text-input"
                type="text"
                name="title"
                value="{{page.title}}">
                {% if warnings.title %}<br>
                <span class="warning-text">
                  Title is required and shouldn't be
                  too long (i.e.,< 500 bytes).
                </span>
                {% endif %}
            </div>
          </div>
          <div class="row">
            <div class="cell label">
              Link Name*:
            </div>
            <div class="cell input">
              <input
                class="text-input"
                type="text"
                name="button_name"
                value="{{page.button_name}}">
                {% if warnings.button_name %}<br>
                <span class="warning-text">
                Link Name is required and should be as short as is useful.
                </span>
                {% endif %}
            </div>
          </div>
          <div class="row">
            <div class="cell label">
              Path:
            </div>
            <div class="cell input">
              <input
                class="text-input"
                type="text"
                name="path"
                value="{{page.path}}">
                {% if warnings.path %}<br>
                <span class="warning-text">
                Path should be unique.
                </span>
                {% endif %}
             </div>
          </div>

          <div class="row">
            <div class="cell label">
              Body*:
            </div>
            <div class="cell input">
              {% if warnings.body %}<br>
              <span class="warning-text">Body is required.</span>
              {% endif %}
              <div id="content-editor-toolbar"></div>
              <div id="content-editor"></div>
              <textarea
                id="body"
                name="body">{{page.body|default_if_none:""|escape}}</textarea>
            </div>
          </div>

          <div class="row">
            <div class="cell label important">
              Published:
            </div>
            <div class="cell input">
              <input
                type="checkbox"
                name="is_published"
                {% if page.is_published %}
                checked="true"
                {% endif %} >
                {% if warnings.published %}<br>
                <span class="warning-text">
                Come on it's a checkbox.
                </span>
                {% endif %}
          </div>
        </div>
      </div>
    </div>
    
    
    <h3 id="meta" class="animated-zippy">Meta</h3>
    <div id="meta-content">
      <div class="table">
        <div class="row">
          <div class="cell label">
            Canonical:
          </div>
          <div class="cell input">
            <input
              class="text-input"
              type="text"
              name="canonical"
              value="{{page.canonical_url}}">
              {% if warnings.cannonical %}<br>
              <span class="warning-text">
              Cannonical shouldn't be too long (i.e., < 500 bytes).
              </span>
              {% endif %}
          </div>
        </div>
        <div class="row">
          <div class="cell label">
            Keywords:
          </div>
          <div class="cell input">
            <textarea
              class="textarea-small"
              name="keywords">{{page.keywords}}</textarea> (comma, separated,
            keywords)
            {% if warnings.keywords %}<br>
            <span class="warning-text">
            Keywords should be comma separated strings.
            </span>
            {% endif %}
          </div>
        </div>
        <div class="row">
          <div class="cell label">
            Description:
          </div>
          <div class="cell input">
            <textarea
              class="textarea-med"
              name="description">{{page.description}}</textarea>
              {% if warnings.description %}<br>
              <span class="warning-text">
              Description should be text only.
              </span>
              {% endif %}
          </div>
        </div>
        <div class="row">
          <div class="cell label">
            NoIndex:
          </div>
          <div class="cell input">
            <input
              type="checkbox"
              name="noindex"
              {% if page.noindex %}
              checked="true"
              {% endif %} >
              {% if warnings.noindex %}<br>
              <span class="warning-text">
              Come on, it's a checkbox.
              </span>
              {% endif %}
          </div>
        </div>
        <div class="row">
          <div class="cell label">
            NoFollow:
          </div>
          <div class="cell input">
            <input
              type="checkbox"
              name="nofollow"
              {% if page.nofollow %}
              checked="true"
              {% endif %} >
              {% if warnings.nofollow %}<br>
              <span class="warning-text">
              Come on it's a checkbox.
              </span>
              {% endif %}
          </div>
        </div>
        <div class="row">
          <div class="cell label">
            NoArchive:
          </div>
          <div class="cell input">
            <input
              type="checkbox"
              name="noarchive"
              {% if page.noarchive %}
              checked="true"
              {% endif %} >
              {% if warnings.noarchive %}<br>
              <span class="warning-text">
              Come on it's a checkbox.
              </span>
              {% endif %}
          </div>
        </div>
        <div class="row">
          <div class="cell label">
            NoSnippet:
          </div>
          <div class="cell input">
            <input type="checkbox" name="nosnippet" value="true"
              {% if page.nosnippet %} checked="true" {% endif %}>
              {% if warnings.nosnippet %}<br>
                <span class="warning-text">
                  How do you mess up checking a box?
                </span>
              {% endif %}
          </div>
        </div>
        <div class="row">
          <div class="cell label">
            NoODP:
          </div>
          <div class="cell input">
            <input
              type="checkbox"
              name="noodp"
              {% if page.noodp %}
              checked="true"
              {% endif %}
              value="true">
              {% if warnings.noodp %}<br>
              <span class="warning-text">
                Your managed to mess up checking an unrequired
                checkbox. How'd you do that?</span>
              {% endif %}
          </div>
        </div>
      </div>
    </div>
    <div class="table">
      <div class="row">
        <div class="cell label">
          <input type="submit" name="save" value="Save">
        </div>
        <div class="cell input">
          <input type="submit" name="done" value="Done">
          <input type="submit" name="cone" value="Cancel">
          <span class="required important">* Required</span>
        </div>
      </div>
    </div>
  </form>
{% else %}
  <h3>
    <a href="/admin/pages?action=new">+ New Page</a>
  </h3>
  <div class="table">
      <div class="row">
        <div class="cell th">Action</div>
        <div class="cell th">Title</div>
        <div class="cell th">Author - Created</div>
        <div class="cell th">Author - Updated</div>
        <div class="cell th">Published</div>
      </div>

    {% ifnotequal pages.count 0 %}
    {% for page in pages %}
      <div class="row">
        <div class="cell">
        <a href='/admin/pages?action=edit&page={{page.key}}'>Edit</a> |
        <a href='/admin/pages?action=delete&page={{page.key}}'>Delete</a>
        </div>
        <div class="cell">
        <a
        href="/{{page.path}}">
            {{page.title}}
        </a>
        </div>
        <div class="cell">
          {{page.author.nickname}} - {{page.draft_date|date:"Y/m/d"}}
        </div>
        <div class="cell">
          {{page.updated_by.nickname|default_if_none:"N/A"}} - {{page.edit_date|date:"Y/m/d"}}
        </div>
        <div class="cell">
          {% if page.is_published %}
            {{page.publish_date|date:"Y/m/d"}}
          {%else %}
            <span style="color:red">False</span>
          {% endif %}
        </div>
      </div>
    {% endfor %}
    {% endifnotequal %}
    </div>
{% endif %}
{% endblock %}
